#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;

class Solution {
public:
    int firstUniqChar(string s) {
        int hash[256];
        memset(hash, 0, sizeof(hash));
        for (int i = 0; i < s.size(); i++)
        {
            ++hash[s[i]];
        }
        for (int i = 0; i < s.size(); i++)
        {
            if (hash[s[i]] == 1)
                return i;
        }
        return -1;
    }

    string multiply(string num1, string num2) {
        if (num1 == "0" || num2 == "0")
            return "0";
        reverse(num1.begin(), num1.end());
        reverse(num2.begin(), num2.end());
        string ans(num1.size() + num2.size(), '0');
        int next = 0;
        for (int i = 0; i < num1.size(); i++)
        {
            for (int j = 0; j < num2.size(); j++)
            {
                next += (num1[i] - '0') * (num2[j] - '0') + ans[i + j] - '0';
                ans[i + j] = '0' + next % 10;
                next /= 10;
            }
            if (next > 0) {
                ans[i + num2.size()] = '0' + next;
                next = 0;
            }
        }
        if (ans.back() == '0') {
            ans.pop_back();
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }

    string reverseWords(string s) {
        int start = 0;
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] == ' ')
            {
                reverse(s.begin() + start, s.begin() + i);
                start = i + 1;
            }
        }
        reverse(s.begin() + start, s.end());
        return s;
    }

};